<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.hkunderground.blog.helper.PropertiesHelper" %>
<%@ page import="com.hkunderground.blog.helper.ConstantHelper" %>
<%@ page import="com.hkunderground.blog.helper.UtilityHelper" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Add entry</title>
</head>
<body>
<%
	UserService userService = UserServiceFactory.getUserService();
	User user = userService.getCurrentUser();

  	if (user != null) 
  	{
  		//check rather it is allowed user
  		if (!PropertiesHelper.isBlogUser(user.getEmail()))
  		{
 %>
 			No blog entry for user = <%= user.getEmail() %>
 <% 			
  		}
  		else
  		{
%>
 <form action="/addentry" method="post">
    <div>Title: <input type="text" name="<%= ConstantHelper.PARA_TITLE %>" size="60"></div>
    <div>Date: <%= UtilityHelper.getCurrDateMMMMDDYYYY_24H() %><input type="hidden" name="<%= ConstantHelper.PARA_DATE %>" value="<%= UtilityHelper.getCurrDateMMMMDDYYYY_24H() %>"> </div>
    <div>Content: <textarea name="<%= ConstantHelper.PARA_CONTENT %>" rows="10" cols="60"></textarea></div>
    <div>Tag(s): <input type="text" name="<%= ConstantHelper.PARA_TAG %>" size="20"> <input type="text" name="<%= ConstantHelper.PARA_TAG %>" size="20"> <input type="text" name="<%= ConstantHelper.PARA_TAG %>" size="20"></div>
    <div><input type="submit" value="Submit" /></div>
  </form>
<%  			
  		}//!PropertiesHelper.isBlogUser(user.getEmail())
  	}
  	else
  	{
  		//go signin dude
%>
  		<a href="<%= userService.createLoginURL(request.getRequestURI()) %>">Sign in to blog</a>
<%
  	}//if (user != null) 
%>



</body>
</html>